package com.koron.device.bean;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author twcao
 * @title: EquipmentChangeVO
 * @projectName GDH_EAM_V2
 * @description: 设备异动
 * @date 2022/2/1711:06
 */
@Data
@ApiModel("设备异动详情")
public class EquipmentChangeVO extends EquipmentChange {

    @ApiModelProperty("异动的设备")
    private List<ChangeEquip> equipments;

    @ApiModelProperty("异动的设备名称，逗号分隔")
    private String equipmentName;

    @ApiModelProperty("异动的参数")
    private List<EquipmentChangeParam> params;

    @ApiModelProperty("当前节点名称")
    private String curNodeName;

    @ApiModelProperty("当前节点审批人姓名，多个之间，逗号分隔")
    private String curNodeUserNames;

    public String getEquipmentName() {
        if(StringUtils.isNotBlank(equipmentName)) {
            return this.equipmentName;
        }
        return String.join(",", equipments.stream().map(ChangeEquip::getEquipName).collect(Collectors.toList()));
    }
}
